<template>
	<view class="margin-top">
		<view class="margin-top margin-left flex align-center bg-white lines-black" >
			<view class="">
				描述相符
			</view>
			<view class="margin-left lines-black">
				<uni-rate :value="star" @change="onChange" />
			</view>
		</view>
		<view class="margin solid radius padding">
			<textarea maxlength="500" @input="textareaInput" placeholder="宝贝满足你的期待吗？" style="width: 100%;"></textarea>
		</view>
		<view class="padding">
			<button class="cu-btn block bg-blue margin-tb-sm lg" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import uniRate from '@/components/uni-rate/uni-rate.vue'
	
	export default {
		components: {
			uniRate
		},
		data() {
			return {
				star:5,
				content:"",
				param:{}
			}
		},
		onLoad(option){
			var data = JSON.parse(option.data);
			this.param = data.param;
		},
		methods: {
			onChange(e) {
				this.star = e.value;
			},
			textareaInput(e) {
				this.content = e.detail.value
			},
			submit:function(){
				var param = {
					start:this.star,
					content:this.content,
					userId:this.userInfo.id,
					userName:this.userInfo.nickName,
					orderId:this.param.orderId,
					orderNo:this.param.orderNo,
					goodsId:this.param.goodsId,
					goodsName:this.param.goodsName,
					skuId:this.param.skuId,
					skuName:this.param.skuName,
					shopId:this.param.shopId
				}
				var that = this;
				that.$api.req(param,"/comment/save").then((res)=>{
					var d = res.data;
					if(d.success){
						that.$api.msg("评价成功！");
						uni.redirectTo({
							url:"order?state=0"
						})
					}else{
						that.$api.msg(d.msg)
					}
				})
			}
		}
	}
</script>

<style>
	page{
		background: #ffffff;
	}
	uni-app{
		background: #ffffff;
	}
</style>
